<?php
$profileModifiable = false;
$contactModifiable = false;
$socialModifiable = false;
$photoModifiable = false;
?>
<div class="span12" style="height:30px;">

</div>
<div class="span8">
    <ul class="nav nav-tabs" id="myTab">
        <li class="active"><a href="#photo">Photo</a></li>
        <li ><a href="#profile">Profile</a></li>
        <li><a href="#contact">Contact </a></li>
        <li><a href="#social">Social </a></li>
    </ul>

    <div class="tab-content">
        <div class="tab-pane" id="profile">
            <form action="<?php echo site_url("profile/saveProfile"); ?>" id="frm_profile" method="POST">
                <div class="span2 label-profile" >First name</div>
                <div class="span2 value-profile">
                    <?php
                    if (isset($user->firstname)) {
                        echo $user->firstname;
                    }
                    ?>
                </div>
                <div class="span2">
                    &nbsp;
                </div>
                <div class="clear"></div>
                <div class="span2 label-profile" >Last name</div>
                <div class="span2 value-profile">
                    <?php
                    if (isset($user->lastname)) {
                        echo $user->lastname;
                    }
                    ?>
                </div>
                <div class="span2">
                    &nbsp;
                </div>
                <div class="clear"></div>
                <div class="span2 label-profile" >Email</div>
                <div class="span2 value-profile">
                    <?php
                    if (isset($user->mail)) {
                        echo $user->mail;
                    }
                    ?>
                </div>
                <div class="span2">
                    &nbsp;
                </div>
                <div class="clear"></div>
                <?php
                
                /*<!--           
                             Password input
                            <div class="control-group">
                                <label class="control-label" for="passwordinput">Password</label>
                                <div class="controls">
                
                if (isset($user->password)) {
                    echo $user->password;
                } else {
                    ?>                                
                    <?php
                }
                ?>
                
                                </div>
                            </div>-->

                <!-- Multiple Radios (inline) -->
                 * */
                ?>

                <div class="span2 label-profile" >Gender</div>
                <div class="span2 value-profile">
                    <?php
                    if (isset($user->sexe)) {
                        echo $user->sexe == "F" ? "Woman" : "Man";
                    }
                    ?>
                </div>
                <div class="span2">
                    &nbsp;
                </div><div class="clear"></div>

                <!-- Birthday input-->
                <div class="span2 label-profile" >Birthday</div>
                <div class="span2 value-profile">
                    <?php
                    if (isset($user->birthday)) {
                        echo $user->birthday;
                    } 
                    /*else {
                        $profileModifiable = true;
                        ?>

                        <div class="input-append">
                            <input value="31/01/1995" 
                                   style="cursor: pointer; background-color: white; width: 200px; margin-left: 0px;" 
                                   readonly="readonly" name="birthday" 
                                   type="text" placeholder="Birthday" class="input-xlarge birthday">
                            <button onclick="$('.birthday').val('');
                                        return false;" class="btn">X</button>  
                        </div>
                        <?php
                    }
                     * */
                     
                    ?>
                </div>
                <div class="span2">
                    &nbsp;
                </div>
                <div class="clear"></div>

                <div class="span2 label-profile" >Presentation</div>
                <div class="span2 value-profile">
                    <?php
                    if (isset($user->presentation)) {
                        echo $user->presentation;
                    } 
                    /*else {
                        $profileModifiable = true;
                        ?>
                        <textarea id="presentation" name="presentation"></textarea>
                        <?php
                    }
                     * 
                     */
                    ?>
                </div>
                <div class="span2">
                    &nbsp;
                </div>
                <div class="clear"></div>
                <?php if ($profileModifiable) {
                    ?>
                    <!--                    <div class="span2" style="text-align: right;">
                                            <div class="controls">
                                                <button id="updateprofile" name="updateprofile" class="btn btn-success">Update Profile</button>
                                            </div>
                                        </div>-->
                    <div class="span3">
                        <div class="controls">
                            <button id="saveprofile" name="saveprofile" class="btn btn-primary">Save Profile</button>
                        </div>
                    </div>
                    <div class="clear"></div>
                <?php } ?>
            </form>
        </div>

        <div class="tab-pane" id="contact">
            <form id="frm_contact" action="<?php echo site_url("profile/saveContact"); ?>" method="POST">
                <div class="span2 label-profile" >City</div>
                <div class="span2 value-profile">
                    <?php
                    if (isset($user->city)) {
                        echo $user->city;
                    }
                    /*else {
                        $contactModifiable = true;
                        ?>
                        <input id="City" name="city" type="text" placeholder="City" class="input-xlarge">
                        <?php
                    }
                     * 
                     */
                    ?>
                </div>
                <div class="span2">
                    &nbsp;
                </div>
                <div class="clear"></div>

                <!-- Text input-->
                <div class="span2 label-profile" >Country</div>
                <div class="span2 value-profile">
                    <?php
                    if (isset($user->country)) {
                        echo $user->country;
                    }
                    /* else {
                        $contactModifiable = true;
                        ?>
                        <input id="Country" name="country" type="text" placeholder="Country" class="input-xlarge">
                        <?php
                    }
                     * 
                     */
                    ?>
                </div>
                <div class="span2">
                    &nbsp;
                </div>
                <div class="clear"></div>

                <!-- Text input-->
                <div class="span2 label-profile" >Mobile</div>
                <div class="span2 value-profile">
                    <?php
                    if (isset($user->mobile)) {
                        echo $user->mobile;
                    } 
                    /*else {
                        $contactModifiable = true;
                        ?>
                        <input id="Mobile" name="mobile" type="text" placeholder="Mobile" class="input-xlarge">
                        <?php
                    }
                     * 
                     */
                    ?>
                </div>
                <div class="span2">
                    &nbsp;
                </div>
                <div class="clear"></div>
                <?php if ($contactModifiable) {
                    ?>
                    <!--                    <div class="span2" style="text-align: right;">
                                            <div class="controls">
                                                <button id="updatecontact" name="updatecontact" class="btn btn-success">Update Contact</button>
                                            </div>
                                        </div>-->
                    <div class="span3">
                        <div class="controls">
                            <button id="savecontact" name="savecontact" class="btn btn-primary">Save Contact</button>
                        </div>
                    </div>
                    <div class="clear"></div>
                    <?php
                }
                ?>
            </form>
        </div>
        <div class="tab-pane" id="social">
            <form method="POST" id="frm_contact" action="<?php echo site_url("profile/saveSocial"); ?>" >
                <div class="span2 label-profile" >Facebook URL</div>
                <div class="span5 value-profile">
                    <?php
                    if (isset($user->networks[0]->id)) {
                        if ($user->networks[0]->id == 1) {
                            echo "<a target='_blank' href='http://" . $user->networks[0]->url . "'>" . $user->networks[0]->url . "</a>";
                        }
                    }/* else {
                        $socialModifiable = true;
                        ?>
                        <input id="fb" name="fb" type="text" placeholder="Facebook URL" class="input-xlarge">
                        <p class="help-block">exemple : www.facebook.com/myfbprofile</p>
                        <?php
                    }
                     * 
                     */
                    ?>
                </div>
                <div class="clear"></div>

                <div class="span2 label-profile" >Twitter URL</div>
                <div class="span2 value-profile">
                    <?php
                    if (isset($user->networks[1]->id)) {
                        if ($user->networks[1]->id == 2) {
                            echo "<a target='_blank' href='http://" . $user->networks[1]->url . "'>" . $user->networks[1]->url . "</a>";
                        }
                    } /*else {
                        $socialModifiable = true;
                        ?>
                        <input id="twitter" name="twitter" type="text" placeholder="Twitter Profile" class="input-xlarge">
                        <?php
                    }
                     * 
                     */
                    ?>
                </div>
                <div class="span2">
                    &nbsp;
                </div>
                <div class="clear"></div>

                <?php if ($socialModifiable) {
                    ?>
                    <!--                    <div class="span3" style="text-align: right;">
                                            <div class="controls">
                                                <button id="updatecontact" name="updatesocial" class="btn btn-success">Update Social information</button>
                                            </div>
                                        </div>-->
                    <div class="span3">
                        <div class="controls">
                            <button id="savecontact" name="savesocial" class="btn btn-primary">Save social information</button>
                        </div>
                    </div>
                    <div class="clear"></div>
                    <?php
                }
                ?>
            </form>
        </div>

        <div class="tab-pane active" id="photo">
            <form method="POST" id="frm_photo" action="<?php echo site_url("profile/saveTof"); ?>" enctype="multipart/form-data" >
                <div class="span2 label-profile" >Your photo</div>
                <div class="span2 value-profile" style="min-height: 100px;">
                    <?php
                    if (isset($user->tof)) {
                        ?>
                        <img src='<?php echo css_url() . "../pht/" . $user->tof; ?>'/>
                        <?php
                    } else {
                        $photoModifiable = true;
                        echo $user->firstname." has no photo !" ;
                    }
                    ?>
                </div>
                <div class="span2">
                    &nbsp;
                </div>
                <div class="clear"></div>
                <?php if ($photoModifiable) {
                    ?>
                    <!--                    <div class="span2" style="text-align: right;">
                                            <div class="controls">
                                                <button id="updatephoto" name="updatephoto" class="btn btn-success">Update photo</button>
                                            </div>
                                        </div>-->
                    <div class="span3">
                        <div class="controls">
                            <input type="submit" id="savephoto" name="savephoto" class="btn btn-primary" value="Save photo" />
                        </div>
                    </div>
                    <div class="clear"></div>
                <?php } ?>
            </form>
        </div>
<!--        <pre>
        <?php
        //  print_r($user);
        ?>
        </pre>-->
        <script>
                                $('#myTab a').click(function(e) {
                                    e.preventDefault();
                                    $(this).tab('show');
                                })

        </script>

    </div>


